<?php
	$brand_id = $params[0];

	if($_SERVER["REQUEST_METHOD"]=='POST') {
		$title			= strip_tags($_POST['title']);
		$detail			= $_POST['detail'];
		$url			= stripBlank($title);
		$ip				= getUserIP();

		$upload_fieldname	= 'thumb';
		$upload_fullpath	= '../contents/brand/'.md5('thumb'.time()).basename($_FILES[$upload_fieldname]['name']);
		if (move_uploaded_file($_FILES[$upload_fieldname]['tmp_name'], $upload_fullpath)) {
			$upload_sql = ", `thumb` = '". basename($upload_fullpath) ."'";
		}

		$sql = "UPDATE `tbl_brand` SET `title` = '$title', `url` = '$url' , `detail` = '$detail' $upload_sql WHERE  `brand_id` = '$brand_id' LIMIT 1;";
		mysql_query($sql);
		redirect('../');
		exit;
	}

	$sql = "SELECT * FROM `tbl_brand` WHERE `brand_id` = '$brand_id' LIMIT 1";
	$query = mysql_query($sql);
	while($result = mysql_fetch_assoc($query)) {
		$title		= $result['title'];
		$detail		= $result['detail'];
		$thumbHTML	= $result['thumb'] ? "<img src=\"/thumb/150/zc/contents/brand/{$result['thumb']}\" /><br />": "";
	}
	mysql_free_result($query);


	include 'ckeditor/ckeditor.php';
	include 'ckeditor/ckfinder/ckfinder.php';
	
	$ckeditor = new CKEditor();
	$ckeditor->returnOutput			= true;
	$ckeditor->basePath				= '/backend/ckeditor/';
 
	CKFinder::SetupCKEditor($ckeditor, '/backend/ckeditor/ckfinder/');
	$detailHTML = $ckeditor->editor('detail',$detail);
?>